require.config({
    baseUrl: "js",
    paths: {
        jquery: "lib/jquery-2.1.4.min",
        bootstrap: "../assets/bootstrap/js/bootstrap",
        datetimepicker: "../assets/datetimepicker/js/bootstrap-datetimepicker",
        datetimepickerLn: "../assets/datetimepicker/js/locales/bootstrap-datetimepicker.zh-CN",
        checkLogin: "common/checkLogin",
        text: "lib/text",
        artTemplate: "lib/template-web",
        common: "common/api",
        layer: "../assets/layui/lay/modules/layer",
        print: "lib/jQuery.print",
        tippy: "lib/tippy"
    },
    shim: {
        bootstrap: {
            deps: ["jquery"],
            exports: 'bootstrap'
        },
        datetimepicker: {
            deps: ["jquery", "bootstrap"],
            exports: 'datetimepicker'
        },
        datetimepickerLn: {
            deps: ["datetimepicker"],
        },
        layer: {
            deps: ["jquery"]
        },
        print: {
            deps: ["jquery"]
        },
        tippy: {
            deps: ["jquery"]
        }
    }
});

require(["jquery", "artTemplate", "common", "tippy", "jkjy_fkzg", "jkjy_hjss", "jkjy_hjzlk", "jkjy_jycp", "jkjy_jyjh", "bootstrap", "datetimepicker", "datetimepickerLn", "layer"],
    function ($, art, common, tippy, fkzg, hjss, hjzlk, jycp, jyjh) {

        /** 初始化日期控件 **/
         window.init_datetimepicker_ymd = function () {
             $(".form_datetime").datetimepicker({
                 format: 'yyyy-mm-dd',
                 language: 'zh-CN',
                 weekStart: 1,
                 bootcssVer: 3,
                 todayBtn: 1,
                 autoclose: 1,
                 todayHighlight: true,
                 startView: 2,
                 minView: 2,
                 pickerPosition: 'bottom-right',
                 forceParse: 0,
                 keyboardNavigation: 1,
                 forceParse: 1
             });
             $(".datetime_now").val(common.dateNowYmd());
         };
         init_datetimepicker_ymd();

         window.init_datetimepicker_ymdsms = function () {
             $(".form_datetime2").datetimepicker({
                 format: 'yyyy-mm-dd hh:ii:ss',
                 language: 'zh-CN',
                 weekStart: 1,
                 bootcssVer: 3,
                 todayBtn: 1,
                 autoclose: 1,
                 todayHighlight: true,
                 startView: 2,
                 minView: 0,
                 pickerPosition: 'bottom-right',
                 keyboardNavigation: 1,
                 forceParse: true
             });
         };
         init_datetimepicker_ymdsms();


        //模块跳转
        $("div.sub_menu_content").on("click", function () {
            var $that = $(this);
            $that.addClass("active").siblings(".sub_menu_content").removeClass("active");
            var m = $that.data("module");
            var navMenu = '<li>首页</li>' + '<li class="active">' + m + '</li>';
            $("#nav-top").html(navMenu);
            $("div.datetimepicker").remove();
            switch (m) {
                case "教育计划":
                    jyjh()
                    break;
                case "患教实施":
                    hjss()
                    break;
                case "教育测评":
                    jycp()
                    break;
                case "反馈整改":
                    fkzg()
                    break;
                case "患教资料库":
                    hjzlk()
                    break;

                default:
                    break;
            }
        })
        $("div.sub_menu_content").eq(1).click();


        $("#login_out").on("click", function () {
            $.removeCookie('JSESSIONID');
            $.removeCookie('loginName');
            $.removeCookie('loginPwd');
            //跳转到登录页
            location.href = "exit.shtml";
        });

        //点击日期控件旁边的日历图标 - 弹出时间选择框
	$("body").off("click.show_time").on("click.show_time","img.form_datetime_",function(e){
		e.stopPropagation();
		$(this).siblings("input.datetime_now").focus();
		return false;
	})
        //判断容器是否出现滚动条，设置顶部标题行右侧的padding
        function setPaddingR(tag1, tag2, width) {
            var w = width || "17px";
            try {
                if ($(tag1)[0].scrollHeight > $(tag1)[0].clientHeight || $(tag1)[0].offsetHeight > $(tag1)[0].clientHeight) {
                    $(tag2).css("padding-right", w);
                } else {
                    $(tag2).css("padding-right", "0");
                }
            } catch (e) {}
        };


    });